#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define rep(i, x, y) for(int i = (x); i <= (y); i++) 
#define per(i, x, y) for(int i = (x); i >= (y); i--)

using namespace std;

using ll = long long;
using db = double;
using pii = pair < ll , int >;
using vec = vector < int >;
using veg = vector < pii >;

int read() {
	int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch == '-', ch = getchar(); 
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar(); return f ? -x : x;
}

const int N = 2e5 + 10;

int pre[N], nxt[N], n;
ll ans, a[N];
priority_queue < pii > q;
bool v[N];

void del(int x) {
	v[x] = true; nxt[pre[x]] = nxt[x]; pre[nxt[x]] = pre[x];
}

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in", "r", stdin);
#endif
	n = in; rep(i, 1, n) a[i] = in, nxt[i] = i + 1, pre[i] = i - 1; a[0] = a[n + 1] = -1e18;
	rep(i, 1, n) q.push({ a[i], i });
	rep(i, 1, (n + 1) >> 1) {
		while(v[q.top().se]) q.pop();
		int x = q.top().se; ll v = q.top().fi; ans += v; printf("%lld\n", ans); q.pop();
		int l = pre[x], r = nxt[x]; a[x] = (a[r] + a[l] - a[x]);
		if(l >= 1 && r <= n) q.push({ a[x], x });
		del(l); del(r);
	}
	return 0;
}
